package com.ruoyi.pms.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;

import com.ruoyi.pms.domain.TaskAssmt;
import com.ruoyi.pms.service.TaskAssmtService;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;

import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 任务考核Controller
 * 
 * @author ruoyi
 * @date 2024-12-09
 */
@RestController
@RequestMapping("/pms/assmt")
public class TaskAssmtController extends BaseController
{
    @Autowired
    private TaskAssmtService taskAssmtService;

    /**
     * 查询任务考核列表
     */
    @GetMapping("/getData")
    public AjaxResult getData(TaskAssmt taskAssmt)
    {
        startPage();
        List<TaskAssmt> list = taskAssmtService.selectPmsProjectTaskAssmtList(taskAssmt);
        if(list.size()>0) {
            return success(list.get(0));
        } else {
            TaskAssmt rtTaskAssmt = new TaskAssmt();
            rtTaskAssmt.setTaskId(taskAssmt.getTaskId());
            rtTaskAssmt.setScore(100d);
            return success(rtTaskAssmt);
        }
    }

    /**
     * 新增任务考核
     */
    @PreAuthorize("@ss.hasPermi('task:assmt:add')")
    @Log(title = "任务考核", businessType = BusinessType.INSERT)
    @PostMapping(value = "add")
    public AjaxResult add(@RequestBody TaskAssmt pmsProjectTaskAssmt)
    {
        return toAjax(taskAssmtService.insertPmsProjectTaskAssmt(pmsProjectTaskAssmt));
    }
}
